<template>
  <div class="collect-page">
    <van-nav-bar fixed title="我的收藏"/>
    <van-list v-model='loading' :finished="finished" finished-text="不要拉了，没了" @load="onload">
        <article-item v-for="item in list" :key="item.id" :item="item"></article-item>
    </van-list>
  </div>
</template>

<script>
import { getArticlesCollect } from '@/api/article'
export default {
  name: 'collect-page',
  data () {
    return {
      loading: false,
      finished: false,
      list: [],
      page: 1
    }
  },
  methods: {
    async onload () {
      // 异步更新数据
      const { data: { data } } = await getArticlesCollect({ page: this.page })
      // console.log(data)
      this.list.push(...data.rows)
      this.loading = false
      if (this.page === data.pageTotal || !data.rows.length) {
        this.finished = true
      } else {
        this.page++
      }
    }
  }
}
</script>

<style lang="less" scoped>
.collect-page {
  margin-bottom: 50px;
  margin-top: 44px;
}
</style>
